home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 2 / Mac Magazin and MacEasy Magazine CD - Issue 02.iso / Sharewarebibliothek / Applikationen / Alpha.5.81 folder / Tcl / SystemCode / procs.tcl~ < prev    next >
Text File  |  1994-03-08  |  17KB  |  714 lines

  1. #==============================================================================
  2. proc normalLeftBracket {} {
  3.     insertText "\{"
  4. }
  5. proc normalRightBracket {} {
  6.     insertText "\}"
  7. }
  8. bind '\[' <zs>  normalLeftBracket
  9. bind '\]' <zs>  normalRightBracket
  10.             
  11. # Select the next or current word. If word already selected, will go to next.
  12. proc hiliteWord {} {
  13.     if {[getPos]!=[selEnd]}    forwardChar
  14.     forwardWord
  15.     set start [getPos]
  16.     backwardWord
  17.     select $start [getPos]
  18. }
  19.  
  20. bind 'h' <z> hiliteWord
  21.  
  22. #================================================================================
  23. # Mode variables
  24. #================================================================================
  25. # For mark stack.
  26. set markName 0
  27. set markStack ""
  28.  
  29. # mapping of windows to current modes.
  30. set winModes("") ""
  31.  
  32. # making vars local to windows
  33. set localVars { optionIsMeta wordBreak wordBreakPreface wordWrap 
  34.     fillColumn leftFillColumn tabSize elecLBrace elecRBrace electricSemi 
  35.     prefixString suffixString funcExpr funcPar sortedIsDefault 
  36.     markSorting }
  37.  
  38. # 'incomingVars' used to hold old var values that have been overwritten in current window
  39.  
  40. #================================================================================
  41. # Handle 'flag' and 'var' menu selections.
  42. #================================================================================
  43. proc editFlag {menu item} {
  44.     global $item localVars incomingVars
  45.  
  46.     set val [expr ([set $item]-1)*-1]
  47.     set $item $val
  48. }
  49.  
  50. proc editVar {menu item} {
  51.     global $item localVars incomingVars
  52.  
  53.     append prmpt "New Value of " $item ": "
  54.     if ![catch {prompt $prmpt [set $item]} res] {
  55.         set $item $res
  56.     }
  57. }
  58.  
  59.  
  60. #=============================================================================
  61. # Hook procs recognized: "openHook", "closeHook", "activateHook", "deactivateHook", 
  62. #                          "suspendHook", "saveasHook", "saveHook", and "resumeHook".
  63. #=============================================================================
  64.  
  65. # Event hooks - set specific modes when files opened.
  66. proc openHook name {
  67.     global winModes
  68.     $winModes($name)
  69.     if {$name == {*Toolserver shell*}} startMPW
  70.     addWinName $name
  71. }
  72.  
  73. # full pathname
  74. proc saveHook name {
  75.     global backup backExtension backDir
  76.     if {![string length [set dir $backDir]]} {
  77.         set dir [file dirname $name]
  78.     }
  79.     if ($backup) {
  80.         catch {rm $dir:[file tail $name]~}
  81.         cp $name $dir:[file tail $name]$backExtension
  82.     }
  83. }
  84.  
  85. # Clean up the mark stack.
  86. proc closeHook name {
  87.     global markStack
  88.     global winModes
  89.     unset winModes($name)
  90.     if [llength $markStack] {
  91.         set markStack [removePat $markStack $name*]
  92.     }
  93.     removeWinName $name
  94. }
  95.  
  96. proc saveasHook {oldName newName} {
  97.     global winModes
  98.     removeWinName $oldName
  99.     addWinName $newName
  100.     setWinMode $newName
  101.     $winModes($newName)
  102. }
  103.  
  104.  
  105. proc activateHook name {
  106.     global winModes
  107.     if {[catch {$winModes($name)}]} {
  108.         setWinMode $name
  109.         $winModes($name)
  110.     }
  111. }
  112.  
  113. proc dirtyHook {name dirty} {
  114.     markMenuItem Wins [file tail $name] $dirty "◊"
  115. }
  116.  
  117.  
  118. #================================================================================
  119.  
  120.  
  121. proc setWinMode name {
  122.     global winModes
  123.     set nm [file tail $name]
  124.     if {[set first [string last " <" $name]] >= 0} {
  125.         set rname [string range $name 0 [expr $first - 1]]
  126.     } else {
  127.         set rname $name
  128.     }
  129.     case $rname in {
  130.         "*.c"         {     set winModes($name) setCMode }
  131.         "*.tex"        {     set winModes($name) setTexMode; winFuncTitle $nm "Sect" }
  132.         "*.cc"        {     set winModes($name) setC++Mode; winFuncTitle $nm "Meth" }
  133.         "*.cp"        {     set winModes($name) setC++Mode; winFuncTitle $nm "Meth" }
  134.         "*.C"        {     set winModes($name) setC++Mode; winFuncTitle $nm "Meth" }
  135.         "*.h"         {     set winModes($name) setCMode }
  136.         "*.f"          {     set winModes($name) setFortranMode }
  137.         "*.tcl"     {     set winModes($name) setTclMode; winFuncTitle $nm "Proc" }
  138.         {*Toolserver\ sh*}    {     set winModes($name) setMPWMode; winFuncTitle $nm "Proc" }
  139.         {*tcl\ sh*}    {     set winModes($name) setShellMode; winFuncTitle $nm "Proc" }
  140.         "*.sty"        {     set winModes($name) setTexMode; winFuncTitle $nm "Sect" }
  141.         "Browser"    {     set winModes($name) setBrowseMode }
  142.         default        {     set winModes($name) setTextMode }
  143.     }
  144. }
  145.  
  146.  
  147. # 'modes' is inspected by alpha for the popup mode menu. 'newMode' is 
  148. # called by Alpha in case of a successful choice.
  149. set modes { C C++ Csh Fort MPW Tcl TeX Text }
  150.  
  151. set modeProcs(C)         setCMode
  152. set modeProcs(C++)         setC++Mode
  153. set modeProcs(Csh)         setShellMode
  154. set modeProcs(Fort)     setFortranMode
  155. set modeProcs(MPW)         setMPWMode
  156. set modeProcs(Tcl)         setTclMode
  157. set modeProcs(TeX)         setTexMode
  158. set modeProcs(Text)     setTextMode
  159.  
  160. proc newMode mode {
  161.     global winModes
  162.     global modeProcs
  163.     
  164.     set name [lindex [winNames -f] 0]
  165.     $modeProcs($mode)
  166.     set winModes($name) $modeProcs($mode)
  167. }
  168.  
  169.  
  170. proc deactivateHook name {
  171. }
  172.  
  173. proc suspendHook name {
  174.     global iconifyOnSwitch
  175.     global suspIconed
  176.     if {$iconifyOnSwitch} {
  177.         set wins [winNames -f]
  178.         foreach win $wins {
  179.             if {![icon -f "$win" -q]} {
  180.                 set suspIconed($win) 1
  181.                 icon -f "$win" -t
  182.             }
  183.         }
  184.     }
  185. }
  186.  
  187. proc resumeHook name {
  188.     global iconifyOnSwitch resumeRevert suspIconed
  189.     if {$iconifyOnSwitch && [info exists suspIconed]} {
  190.         set wins [winNames -f]
  191.         foreach win [array names suspIconed] {
  192.             icon -f "$win" -o
  193.         }
  194.         unset suspIconed
  195.     }
  196.     if {$resumeRevert} {
  197.         set resumeRevert 0
  198.         revert
  199.     }
  200. }
  201.  
  202. # Handles dynamically adding and deleting window names from menu.
  203. proc addWinName name {
  204.     global winNameToNum
  205.     global winNumToName
  206.     global fullNames
  207.     
  208.     for {set i 0} {$i<100} {incr i} {
  209.         if {[catch {set nm $winNumToName($i)} res] == "1"} {
  210.             if {$fullNames != "0"} {
  211.                 set nm $name
  212.             } else {
  213.                 regexp {[^:]*$} $name nm
  214.             }
  215.             if {$i < 10} {
  216.                 addMenuItem -m -l "/$i" Wins $nm
  217.             } else {
  218.                 addMenuItem -m -l "" Wins $nm
  219.             }
  220.             set winNumToName($i) $name
  221.             set winNameToNum($name) $i
  222.             return
  223.         }
  224.     }
  225. }
  226.  
  227. proc removeWinName name {
  228.     global winNameToNum
  229.     global winNumToName
  230.     global fullNames
  231.     
  232.     set num $winNameToNum($name)
  233.     unset winNumToName($num)
  234.     unset winNameToNum($name)
  235.     if {$fullNames == "1"} {
  236.         deleteMenuItem -m Wins $name
  237.     } else {
  238.         regexp {[^:]*$} $name nm
  239.         deleteMenuItem -m Wins $nm
  240.     }
  241. }
  242.  
  243.  
  244. proc menuWin {menu name} {
  245.     global winNameToNum
  246.  
  247.     set nms [array names winNameToNum]
  248.     foreach nm $nms {
  249.         if {[string match *$name $nm] == "1"}  {
  250.             bringToFront $name
  251.             if [icon -q] { icon -f $name -o }
  252.             return
  253.         }
  254.     }
  255.     return "normal"
  256. }
  257.  
  258.  
  259. set lastMode 0
  260.  
  261. # rta  Creating texWasLast variable
  262. set texWasLast 0
  263. # rta Following changed from ThinkC to MPW
  264.  
  265.  
  266. # Modes
  267.  
  268. # Fortran programming mode 
  269. proc setFortranMode {} {
  270.     changeMode "Fort"
  271.     uplevel #0 {
  272.         set elecLBrace 0
  273.         set elecRBrace 0
  274.         set electricSemi 0
  275.         set wordWrap 0
  276.         set funcExpr {^(      |\t)(subroutine|.*function|SUBROUTINE|.*FUNCTION).*\(.*$}
  277.         set sortedIsDefault 0
  278.     }
  279. }
  280.  
  281.  
  282. # Ordinary, default mode
  283. proc setTextMode {} {
  284.     changeMode "Text"
  285.     uplevel #0 {
  286.         set elecLBrace 0
  287.         set elecRBrace 0
  288.         set electricSemi 0
  289.         set wordWrap 1
  290.         set prefixString "> "
  291.         set suffixString " <--"
  292.     }
  293. }
  294.  
  295.  
  296. #================================================================================
  297.  
  298. # Instantiate a global variable to the path of a file (usually an app). As a
  299. # side-effect, make the instantiation permanent by adding a line to 'definitions.tcl'.
  300. proc addAppPath {name var} {
  301.     global $var
  302.     
  303.     if {[catch {getfile "Find '$name' app:"} path]} {return 1}
  304.     set $var $path
  305.  
  306.     addUserLine "set $var \"[quoteExpr2 $path]\""
  307.     return 0
  308. }
  309.  
  310. proc addUserLine {line} {
  311.     global HOME
  312.  
  313.     if {[file exists "$HOME:userStartup.tcl"]} {
  314.         set fid [open "$HOME:userStartup.tcl" "a"]
  315.     } else {
  316.         set fid [open "$HOME:userStartup.tcl" "w"]
  317.     }
  318.     puts $fid $line
  319.     close $fid
  320. }
  321.  
  322.  
  323. proc getFileSig {f} {
  324.     catch {lindex [ls -l $f] 5} var
  325.     return $var
  326. }
  327.  
  328.  
  329. # Look for given app sig in active processes. If not there, try to 
  330. # launch with 'path' prompting for 'path' if necessary.
  331. # Return the real name of the app. Don't switch.
  332. proc checkRunning {name sig path} {
  333.     global $path
  334.     foreach proc [processes] {
  335.         if {[lindex $proc 1] == $sig} {
  336.             return [lindex $proc 0]
  337.         }
  338.     }
  339.     if {![info exists $path] || ![file exists [set $path]]} {
  340.         if {[addAppPath $name $path]} return
  341.     }
  342.     if {[catch {getFileSig [set $path]}]} {
  343.         if {[addAppPath $name $path]} return
  344.     }
  345.     set sig [getFileSig [set $path]]
  346.     if {[catch {launch -f [set $path]}]} {
  347.         error "Problem with script."
  348.     }
  349.     return [file tail [set $path]]
  350. #    return [checkRunning $name $sig $path]
  351. }
  352.  
  353. #================================================================================
  354. # Excalibur is the only Mac spell-checker that I know of which will handle LaTeX as
  355. # well as ordinary text.
  356.  
  357.  
  358. proc spellcheckWindow {} {
  359.     global excaliburPath resumeRevert
  360.  
  361.     catch {checkRunning Excalibur XCLB excaliburPath} name
  362.  
  363.     if {[winInfo dirty]} {
  364.         if {[askyesno "Save '[lindex [winNames] 0]'?"] == "yes"} {
  365.             save
  366.         }
  367.     }
  368.     if {[catch {sendOpenEvent -n $name [lindex [winNames -f] 0]}] } {
  369.         beep 
  370.     } else {
  371.         switchTo $name
  372.     }
  373.     set resumeRevert 1
  374. }
  375.  
  376. proc spellcheckSelection {} {
  377.     global excaliburPath 
  378.  
  379.     catch {checkRunning Excalibur XCLB excaliburPath} name
  380.  
  381.     if {[getPos] == [selEnd]} {
  382.         beep
  383.         message "No selection"
  384.         return;
  385.     }
  386.     copy
  387.     switchTo $name
  388. }
  389.  
  390. menu -n $excaliburMenu {
  391.     "spellcheckWindow"
  392. }
  393. insertMenu    $excaliburMenu
  394.  
  395. #================================================================================
  396.  
  397.  
  398. proc changeMode {newMode} {
  399.     global lastMode
  400.     global savedIsMeta
  401.     global wordBreak
  402.     global wordBreakPreface
  403.     global optionIsMeta
  404.     global latexMenu excaliburMenu thinkMenu toolserverMenu
  405.     
  406.     displayMode $newMode
  407.     if {$lastMode == $newMode} return
  408.     
  409.     case $lastMode in {
  410.         "Tex" {
  411.             set optionIsMeta $savedIsMeta
  412.             set wordBreakPreface {[^a-zA-Z0-9_]}
  413.             set wordBreak {[a-zA-Z0-9_]+}
  414.             set optionIsMeta 1
  415.             catch {removeMenu $latexMenu}
  416.             insertMenu $excaliburMenu
  417.         }
  418.         "Csh" {
  419.             catch {removeMenu "Tcl"}
  420.         }
  421.         "Tcl" {
  422.             catch {removeMenu "Tcl"}
  423.         }
  424.         "BRWZ" {
  425.             catch {removeMenu "Browse"}
  426.         }
  427.         "C" {
  428.             catch {removeMenu    $thinkMenu}
  429.             catch {removeMenu    $toolserverMenu}
  430.         }
  431.          "C++" {
  432.             catch {removeMenu    $thinkMenu}
  433.             catch {removeMenu    $toolserverMenu}
  434.         }
  435.     }
  436.     global mode
  437.     set mode $newMode
  438.     set lastMode $newMode
  439. }
  440.     
  441.  
  442. proc alphaHelp {} {
  443.     global HOME
  444.     edit -r -m "$HOME:Help:    Intro     "
  445. }
  446.  
  447.  
  448. proc tclHelp {} {
  449.     global HOME
  450.     edit -r -m "$HOME:Help: Tcl Manual"
  451. }
  452.  
  453.  
  454. set patternLibrary {
  455.     { "Pascal to C Comments" {        \{([^\}]*)\}} {/* \1 */} }
  456.     { "C++ to C Comments" {//(.*)} {/* \1 */}}
  457. }
  458.  
  459.  
  460. proc dividingLine {} {
  461.     insertText "================================================================================\r"
  462. }
  463. bind 'l' <C> dividingLine
  464.  
  465. proc texDividingLine {} {
  466.     insertText "%================================================================================\r"
  467. }
  468. bind 'l' <C> texDividingLine TeX
  469.  
  470. proc cDividingLine {} {
  471.     insertText "//================================================================================\r"
  472. }
  473. bind 'l' <C> cDividingLine C
  474. bind 'l' <C> cDividingLine C++
  475.  
  476. proc tclDividingLine {} {
  477.     insertText "#================================================================================\r"
  478. }
  479. bind 'l' <C> tclDividingLine Tcl
  480.  
  481.  
  482. #================================================================================
  483.  
  484. if {[catch {info args oldCd}]} {
  485.     rename cd oldCd
  486. }
  487.  
  488. proc cd args {
  489.     global HOME
  490.     if {[llength $args]} {
  491.         oldCd [string trim [eval list $args] "        \{\}"]
  492.     } else {
  493.         oldCd $HOME
  494.     }
  495. }
  496.  
  497. #================================================================================
  498.  
  499. proc getVarValue {} {
  500.     set val [listpick -p {Which var?} [lsort [info globals]]]
  501.     if {![string length $val]} return
  502.     global $val
  503.     alertnote [join [list "'$val' = " [set $val]] ""]
  504. }
  505.  
  506. #================================================================================
  507.     
  508. proc selectParagraph {} {
  509.     set pos [getPos]
  510.     set start [paraStart $pos] 
  511.     set finish [paraFinish $pos]
  512.     goto $start
  513.     select $start $finish
  514. }
  515.  
  516. # wrapText ==  getText ; breakIntoLines ; replaceText
  517. # Remove text from window, transform (join, del-ws), insert back into window.
  518. proc fillTextByPar {from to} {
  519.     set text [getText $from $to]
  520.     regsub -all "\r(\[ \t\]*\r)+" $text "\r\r\r" text
  521.     regsub -all "(\[^\r\])\r" $text "\\1 " text
  522.     regsub -all "\[ \t\]+" $text " " text
  523.     return [breakIntoLines $text]
  524. }
  525.  
  526. proc fillRegionByPar {{start -1} {finish -1}} {
  527. #    # if {[getPos] == [selEnd]} { return}
  528.     if {($start < 0) || ($finish < 0)} {
  529.         set start [lineStart [getPos]]
  530.         set finish [selEnd] }
  531.     if {$start >= $finish} return
  532.     goto $start
  533.     set text [fillTextByPar $start $finish]
  534.     replaceText $start $finish $text "\r"
  535. }
  536.     
  537. #
  538. # join Lines in region -- if no optional args, use selection
  539. #
  540. proc joinRegion {{from -1} {to -1}} {
  541.     if {($from < 0) || ($to < 0)} {    set from [getPos] ; set to [selEnd] }
  542.     if {$from >= $to} return
  543.     set text [getText $from $to]
  544.     regsub -all "\r(\[ \t\]*\r)+" $text "\r\r\r" text
  545.     regsub -all "(\[^\r\])\r" $text "\\1 " text
  546.     replaceText $from $to $text "\r"
  547. }
  548. # WARNING:    regsub ^$ refers to string endpts (not lines)
  549. # FUTURE:    filterLines like perl:
  550. #    replaceText[apply_to_all(cmd,split [getText [getPos] [selEnd]] "\r")]
  551. # OR:    replaceInRegion: dup_\r, $=>\r ??
  552. #
  553.  
  554.  
  555. #
  556. # Remove text from window, transform (delete dup ws), insert back into window.
  557. #
  558. # inputs: message, alertnote, askyesno, listpick, prompt KILLS SELECTION.
  559. # search: bnds = search -forward -regExpr -ignoreCase -matchWords -noabort 
  560. #        -l limit pat pos
  561. proc regsubInRegion {from to srch repl} {
  562.     if {![string length $srch]} return
  563.     if {$from >= $to} return
  564.     set text [getText $from $to]
  565.     regsub -all "$srch" $text "$repl" text
  566.     replaceText $from $to $text
  567. }
  568. #    while {($pos < $to) &&
  569. #          ![catch {search -f 1 -r 1 -i 1 -m 0 "$srch" $pos} mtch]} {
  570. #        set mbeg [lindex $mtch 0]
  571. #        set pos [lindex $mtch 1]
  572. #        replaceText $mbeg $pos $repl }
  573.  
  574. proc backSlashSub {arg} { eval [concat return "\"$arg\""] }
  575.  
  576. proc replaceInRegion {} {
  577.     if [catch {prompt "Search RegExpr:" ""} srch] return
  578.     if [catch {prompt "Replace String:" ""} repl] return
  579.     if {![string length $srch]} return
  580.     regsubInRegion [getPos] [selEnd] \
  581.         [backSlashSub "$srch"] [backSlashSub "$repl"]
  582. }
  583.  
  584. #
  585. # Apply command to each line (or paragraph) in selection ;
  586. #    if no cmd arg then prompts for it
  587. #
  588. proc filterLines {{cmd 0} {parunit 0}} {
  589.     if {$cmd == 0} {
  590.       if {[catch { prompt "Line-filter command: " "" } cmd]} { return } }
  591.     if {![string length $cmd]} return
  592.     set unitStart lineStart
  593.     set unitEnd nextLineStart
  594.     if {$parunit} {
  595.         set unitStart paraStart
  596.         set unitEnd paraFinish }
  597.     set pos [$unitStart [getPos]]
  598.     set finish [selEnd]
  599.     if {$pos >= $finish} return
  600.     goto $pos
  601.     createTMark "filterLend" $finish
  602.     set next [$unitEnd $pos]
  603.     while {(($next > $pos) && ($pos < $finish))} {
  604.         goto $next
  605.         createTMark "filterLnext" $next
  606.         setMark
  607.         goto $pos
  608.     if {[catch [list uplevel #0 "$cmd"] retval]} { altertnote $retval }
  609.         set finish [getTMark "filterLend"]
  610.         gotoTMark "filterLnext"
  611.         set pos [$unitStart [getPos]]
  612.         set next [$unitEnd $pos]]
  613.     }
  614.     removeTMark "filterLend"
  615.     removeTMark "filterLnext"
  616. }
  617.  
  618. proc filterParagraphs {{cmd 0}} { filterLines $cmd 1 }
  619.  
  620. # WARNING: deselecting sets the mark to selEnd
  621. proc sortParagraphs {{from -1} {to -1}} {
  622.     if {($from < 0) || ($to < 0)} {    set from [getPos] ; set to [selEnd] }
  623.     if {$from >= $to} return
  624.     joinRegion {$from $to}
  625.     select [getPos] [nextLineStart [getMark]]
  626.     sortLines
  627.     select [getPos] [getPos]
  628.     regsubInRegion [getPos] [getMark] "\r" "\r\r" 
  629.     wrapRegion
  630. }
  631.  
  632. #
  633. # Sample
  634. #
  635. proc filterRegion {{from -1} {to -1} {cmd 0} {newwin 0}} {
  636.     if {$cmd == 0} {
  637.       if {[catch { prompt "Eval command: " "" } cmd]} { return }
  638.     }
  639.     if {![string length $cmd]} return
  640.     if {($from < 0) || ($to < 0)} {    set from [getPos] ; set to [selEnd] }
  641.     if {$from >= $to} return
  642.     set pos [getPos]
  643.     set text [getText $from $to]
  644.     set text [$cmd $text]
  645.     replaceText $from $to $text "\r"
  646.     goto $pos
  647. }
  648.  
  649. #===========================
  650. # ==== FUNCTIONS (COMMANDS)
  651. #===========================
  652. # ==== Redo History ====
  653. set evalLastCmd ""
  654.  
  655. # Eval one command --- "eval" vs. "catch"
  656. #    # catch:  0_OK == catch cmd retval
  657. #    # set retval [eval [list uplevel #0 "$cmd"]]
  658. #    # catch [list uplevel #0 "$cmd"] retval
  659. #
  660. proc evalCommand {} {
  661.     global evalLastCmd
  662.     if {![catch { prompt "Eval command: " "" } cmd]} {
  663.         set evalLastCmd $cmd
  664.         set retval [eval [list uplevel #0 "$cmd"]]
  665.         message $retval }
  666. }
  667.  
  668. proc evalToText {} {
  669.     global evalLastCmd
  670.     if {![catch { prompt "Eval command: " "" } cmd]} {
  671.         set evalLastCmd $cmd
  672.         catch [list uplevel #0 "$cmd"] retval
  673.         getline "Result:" "$retval" }
  674. }
  675.  
  676. # repeat complex command
  677. proc repeatEval {} {
  678.     global evalLastCmd
  679.     set cmd $evalLastCmd
  680.     if {$cmd == ""} { abortEm ; return }
  681.     set retval [eval [list uplevel #0 "$cmd"]]
  682.     message $retval
  683. }
  684.  
  685. #    Escape current mode for one command
  686. proc execCommand {} {
  687.     global mode
  688.     set saveMode $mode
  689.     changeMode "Text"
  690.     execute
  691.     changeMode $saveMode
  692. }
  693.  
  694. # First, define macros to bypass the electric braces.
  695. proc ordLeftBrace {} {
  696.     insertText "        \{"
  697. }
  698. bind {'['} <cs> ordLeftBrace
  699.  
  700. proc ordRightBrace {} {
  701.     insertText "\}"
  702.     blink [matchIt "\}" [expr [getPos]-1]]
  703. }
  704. bind {']'} <cs> ordRightBrace
  705.     
  706. proc quoteWord {} {
  707.     backwardWord
  708.     insertText "'"
  709.     forwardWord
  710.     insertText "'"
  711. }
  712. bind ''' <z> quoteWord
  713.